<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ include file="/commons/pages/taglibs.jsp" %>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${naviString}</title>
<link href="${ctx}/commons/styles/themes/blue/styles/style.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/commons/scripts/jquery-ui/themes/redmond/jquery-ui.custom.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div align="center">
  <div align="left" style="width:99%">
    <div align="left" class="nav">${naviString}</div>
    <html-el:form action="/manager/StaffWord.do">
      <html-el:hidden property="method" value="save" />
      <html-el:hidden property="mod_id" />
      <html-el:hidden property="queryString" />
      <br />
      <table width="100%" border="0" align="left" cellpadding="1" cellspacing="1" class="datagrid">
        <tr>
          <th colspan="2">员工感言</th>
        </tr>
        <tr>
          <td width="15%" class="title_item"><span style="color: #F00;">*</span><strong>员工姓名：</strong></td>
          <td width="85%"><html-el:text property="user_name" styleId="user_name" style="width:60px;text-align:center;cursor:pointer;" title="请选择员工" onfocus="this.blur()" readonly="true" />&nbsp;
            <html-el:button property="choose_user" styleId="choose_user" value="请选择员工" style="width:80px;cursor:pointer;" styleClass="ui-state-default ui-corner-all" />
          	<html-el:hidden property="user_id" styleId="user_id" />
          </td>
        </tr>
        <tr>
          <td class="title_item"><span style="color: #F00;">*</span><strong>员工感言：</strong></td>
          <td><FCK:editor instanceName="staff_word">
              <jsp:attribute name="value">${hf.map.staff_word}</jsp:attribute>
            </FCK:editor>
            <div>1、此处上传的图片不会自动缩放，请用相关做图软件缩放成您想要的大小或手动调整大小！</div>
            <div>2、点击最后一排倒数第三个按钮可实现全屏编辑</div></td>
        </tr>
        <tr>
          <td class="title_item">&nbsp;</td>
          <td><html-el:button property="save" value=" 保 存 " styleId="save" styleClass="ui-state-default ui-corner-all" style="cursor:pointer;" />
            &nbsp;
            <html-el:reset value=" 重 填 " styleClass="ui-state-default ui-corner-all" style="cursor:pointer;" />
            &nbsp;&nbsp; <span id="loading" style="display:none;"><img src="${ctx}/commons/styles/images/loading.gif" style="vertical-align:middle; margin: 2px;" />数据提交中，请稍候...</span></td>
        </tr>
      </table>
    </html-el:form>
  </div>
</div>
<script type="text/javascript" src="${ctx}/commons/scripts/validator.js"></script>
<script type="text/javascript" src="${ctx}/commons/scripts/jquery.js"></script>
<script type="text/javascript">//<![CDATA[
$(document).ready(function(){
	initStyle();
	
	$("#user_name").attr("datatype","Require").attr("msg","员工姓名必须选择");
		
	var f = document.forms[0];
	$("#save").click(function(){
		if(Validator.Validate(f, 3)) {
			var staff_word = getFCKBody("staff_word");
			if($.trim(staff_word.text()) == "" || staff_word.text() == null){
				alert("员工感言必须填写");
				staff_word.focus();
				return false;
			}
			
			$("#loading").show();
			$("#save").attr("disabled", "true");
			$("#reset").attr("disabled", "true");

			f.submit();
		}
	});
});

$("#choose_user,#user_name").click(function(){
	var returnValue = window.showModalDialog("StaffWord.do?method=chooseUser",window,"dialogWidth:700px;scroll:no;dialogHeight:500px");
	if(returnValue != null) {
		var value = new Array();
		value = returnValue.split(",");
        $("#user_id").val(value[0]);
        $("#user_name").val(value[1]);

        $.ajax({
			type: "POST",
			url: "StaffWord.do",
			data: "method=getStaffWordContent&user_id=" + $("#user_id").val(),
			dataType: "text",
			error: function(request, settings) {alert("数据加载请求失败！"); },
			success: function(content) {
				if(content == "" || content == null) {
					return;
				} else {
					var staff_word = getFCKBody("staff_word");
					if(confirm($("#user_name").val() + "已有感言内容，是否覆盖当前感言内容？")){
						$(staff_word).text("").append(content);
					}
				} 
			}
		});
    } 
});

function getFCKBody(name){
	var iframe_document = $("#" + name + "___Frame",document).get(0).contentWindow.document;
	var xEditingArea = $("#xEditingArea",iframe_document);
	var content = $("iframe",xEditingArea).get(0).contentWindow.document;

	return $(content).find("body");
}

function initStyle(){
	$("input[type='text']").css({border: "1px solid #ccc"});
	$("input[type='submit'],input[type='reset'],input[type='button']").css({border: "1px solid"});
	$("input[type='text'][readonly],input[type='password'][readonly],textarea[readonly]").css({color:"#000"});
    $("input[type='text'],input[type='password'],textarea").not("[readonly]").focus(function(){
    	$(this).addClass("row_focus");
    }).blur(function(){
    	$(this).removeClass("row_focus");
    });
    
	$("textarea").each(function(){
		this.onpropertychange = function () {
			if (this.scrollHeight > 16) this.style.posHeight = this.scrollHeight;
		};
	});
}

//]]></script>
</body>
</html>
